package cn.itcast.bos.service.bc.impl;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.bc.SubAreaDao;
import cn.itcast.bos.domain.bc.Subarea;
import cn.itcast.bos.service.bc.SubAreaService;

@Service("subAreaService")
@Transactional
public class SubAreaServiceImpl implements SubAreaService {
	@Autowired
	private SubAreaDao subAreaDao;

	@RequiresRoles(value = "base")
	// 注解 权限管理无效
	public void addSubarea(Subarea model) {
		subAreaDao.save(model);
	}

	public Page<Subarea> findAll(Pageable pageRequest, Specification specification) {
		return subAreaDao.findAll(specification, pageRequest);
	}

	public Page<Subarea> findAll(Pageable pageRequest) {
		// TODO Auto-generated method stub
		return subAreaDao.findAll(pageRequest);
	}

	public List<Subarea> findAll(Specification<Subarea> specifecation) {
		// TODO Auto-generated method stub
		return subAreaDao.findAll(specifecation);
	}

	public List<Subarea> findAll() {
		// 查询所有未被定区关联的分区...
		return subAreaDao.findByNoAssociationsDecidedZone();
	}

}
